package com.serial.comm.core.exception.enums;

/**
 * @description 响应码配置枚举
 */
public enum ResponseCodeEnum {
    // 系统通用
    SUCCESS(200, "操作成功"),
    OPERATE_FAIL(500, "操作失败"),


    //串口异常
    PORT_IN_USE(801, "串口被占用"),
    NO_SUCH_PORT(802, "未发现对应的有效串口"),
    NOT_A_SERIAL_PORT(803, "串口不可用"),
    READ_DATA_FROM_SERIAL_PORT_FAILURE(804, "从串口读取信息失败"),
    SEND_DATA_TO_SERIAL_PORT_FAILURE(805, "向串口发送信息失败"),
    SERIAL_PORT_INPUTSTREAM_CLOSE_FAILURE(806, "串口输入流关闭失败"),
    SERIAL_PORT_OUTPUTSTREAM_CLOSE_FAILURE(807, "串口输出流关闭失败"),
    SERIAL_PORT_PARAMETER_FAILURE(808, "串口参数出错"),
    TOO_MANY_LISTENERS(809, "监听器过多，程序出现异常"),

    //串口读写异常
    NO_VALID_TELEGRAM(810, "未发现有效的电报信息"),


    //解析过程异常
    EXTRACT_HEADER_FAILURE(701, "解析电报头部信息(HEADER)时异常"),
    EXTRACT_GUID_FAILURE(702, "解析电报唯一标识(GUID)时异常"),
    EXTRACT_PRIORITY_FAILURE(703, "解析电报等级(PRIORITY)时异常"),
    EXTRACT_ORIGIN_FAILURE(705, "解析发电地址(ORIGIN)时异常"),
    EXTRACT_DESTINATION_FAILURE(706, "解析收电地址(DESTINATION)时异常"),
    EXTRACT_TEXT_FAILURE(707, "解析报文内容(TEXT)时异常"),

    //节点未找到
    HEADER_NODE_NOT_FIND(720, "HEADER 节点未找到"),
    PRIORITY_NODE_NOT_FIND(721, "PRIORITY 节点未找到"),
    GUID_NODE_NOT_FIND(722, "GUID 节点未找到"),
    ORIGIN_NODE_NOT_FIND(723, "ORIGIN 节点未找到"),
    DESTINATION_NODE_NOT_FIND(724, "DESTINATION 节点未找到"),
    TEXT_NODE_NOT_FIND(725, "TEXT 节点未找到"),


    HANDLE_BASE_TELEGRAM_FAILURE(601, "解析原始电报时异常");


    private Integer code;
    private String message;

    ResponseCodeEnum(Integer code, String message) {
        this.code = code;
        this.message = message;
    }

    private  ResponseCodeEnum getResponseCodeEnum(Integer code, String message) {
        this.code = code;
        this.message = message;
        return this;
    }

    public final Integer getCode() {
        return this.code;
    }

    public final String getMessage() {
        return this.message;
    }

}